﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data.SqlClient;//命名空间

public partial class khregister : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {

    }

    protected void btnSearch_Click(object sender, EventArgs e)
    {
        string num = txtNum.Text.Trim();
        kh us = new kh();
        us.num = num;//传递给us
        int result = us.IsidExist(us);
        if (result > 0)
        {
            lblMsg.Visible = true;
            lblMsg.Text = "这个账号已经存在！";
            btnSubmit.Enabled = false;
        }
        else
        {
            lblMsg.Visible = true;
            lblMsg.Text = "这个账号可用！";
            btnSubmit.Enabled = true;
        }
    }
    protected void btnSubmit_Click(object sender, EventArgs e)
    {
        string num = txtNum.Text.Trim();
        string pw = txtPw.Text.Trim();
        string idcard = txtIdcard.Text.Trim();
        string name = txtName.Text.Trim();
        string phone = txtPhone.Text.Trim();
        kh tmp = new kh();
        tmp.num = num;
        tmp.pw = pw;
        tmp.idcard = idcard;
        tmp.name = name;
        tmp.phone = phone;
        int result = tmp.Addonekh(tmp);
        if (result > 0)
        {
            Response.Write("<script>alert(\"恭喜你注册成功！\")</script>");
        }
        else
        {
            Response.Write("<script>alert(\"对不起，你注册失败！\")</script>");
        }
    }
    
}